package com.ganlebao.study.springcloudhystrix.basic;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.stereotype.Service;

@Service
public class UserService {

    @HystrixCommand(fallbackMethod = "getDefaultUser")
    public String getUser(String name) throws Exception {
        if ("spring".equals(name)) {
            return "你好,spring";
        } else {
            throw new Exception();
        }
    }


    public String getDefaultUser(String name) {
        return "用户名[" + name + "]不存在";
    }
}
